//
//  HYDatePicker.h
//  HYDatePicker
//
//  Created by crte on 13-11-15.
//  Copyright (c) 2013年 crte. All rights reserved.
//

#import <UIKit/UIKit.h>
#import "MainViewController.h"
/**
 *  导出的时间字符串格式, 想要什么格式的可以自行修改
 */
#define FULL_DATE_FORMAT @"yyyy-MM-dd HH:mm"
#define PLAIN_DATE_FORMAT @"yyyy-MM-dd"

@class HYDatePicker;

/**
 *  finished为NO时, 表示用户没有成功选择时间(为了避免滚动还没停止的情况下,就隐藏了picker这种情况)
 */
typedef void(^HYDatePickerHandler)(HYDatePicker *picker, BOOL finished);

typedef enum {
    HYDatePickerTypeFull = 0,    //年月日时分
    HYDatePickerTypePlain,       //年月日
}HYDatePickerType;

@interface HYDatePicker : UIView

//下面几个属性可以用来单独提取单个时间元素
@property (nonatomic, readonly) int year;
@property (nonatomic, readonly) int month;
@property (nonatomic, readonly) int day;
@property (nonatomic, readonly) int hour;
@property (nonatomic, readonly) int minute;

//是否正在显示
@property (nonatomic, getter = isShowing, readonly) BOOL show;
@property (nonatomic, strong) UIPickerView *pickerView;
//初始化, defaultDate如果不为nil,则picker的滚轮初始位置按defaultDate来显示, 为nil则按当前时间来显示
- (id)initWithDate:(NSDate *)defaultDate type:(HYDatePickerType)type showInView:(UIView *)referView handler:(HYDatePickerHandler)handler;

//显示
- (void)show;

//隐藏,如有需要可自行调用
- (void)hide;

//获取时间对象
- (NSDate *)getDate;

//获取时间字符串, 想要自定义字符串格式可以在上边修改
- (NSString *)getDateString;

@end
